<?php
//DB Created by Rich L. a member in service in Northern Delaware.  Please feel free to share this code wherever it may be useful to alcholoics.  Should you have questons please contact me at sobernerd@gmail.com
require_once ('config/include_paths.php');
require_once('config.php');
$pageTitle = SITE_NAME.' - Search for Meetings'; //must be set after the config.php include
require_once ('dbconnect.php');
require_once ('functions.php');
require_once ('head.php'); 
/* city query */
$city_sql = mysql_query("SELECT DISTINCT city FROM locations ORDER BY city") or die(mysql_error());  
/* group query */
$group_sql =  mysql_query("SELECT groupname FROM groups ORDER BY groupname") or die(mysql_error());
/* meeting type query to populate control*/
$meeting_type_sql = mysql_query("SELECT DISTINCT code, description, meetings.mtg_type_id as id
FROM meeting_types JOIN meetings on meeting_types.id = meetings.mtg_type_id
ORDER BY description") or die(mysql_error());
?>
<body>
<div id="wrapper">
  <?php require_once ('header.php'); ?>
    
        <div id="content">
      <form id="FormName" action="meeting_search_results.php" method="get" name="FormName">
        <table width="500" border="0" cellspacing="5" cellpadding="5" style="width: 396px; height: 242px">
          <tr>
            <td style="text-align:right">Day:</td>
            <td><select name="day" size="1">
                <option value="" selected="selected">All</option>
                <option value="1">Sunday</option>
                <option value="2">Monday</option>
                <option value="3">Tuesday</option>
                <option value="4">Wednesday</option>
                <option value="5">Thursday</option>
                <option value="6">Friday</option>
                <option value="7">Saturday</option>
              </select></td>
          </tr>
          <tr>
            <td style="text-align:right">City:</td>
            <td><select name="city" size="1">
                <option value="" selected="selected">All</option>
                <?php while($row = mysql_fetch_array($city_sql)){
						echo "<option value=\"$row[city]\">$row[city]</option>"; 
						}
					 ?>
              </select></td>
          </tr>
          <tr>
            <td style="text-align:right">Group:</td>
            <td><select name="group" size="1">
                <option value="" selected="selected">All</option>
                <?php while($row = mysql_fetch_array($group_sql)){

						echo "<option value=\"$row[groupname]\">$row[groupname]</option>"; 
						}

					 ?>
              </select></td>
          </tr>
           <tr>
            <td style="text-align:right">Meeting Type:</td>
            <td><select name="meeting_type" size="1">
                <option value="" selected="selected">All</option>
                <?php while($row = mysql_fetch_array($meeting_type_sql)){

						echo "<option value=\"$row[id]\">$row[code]</option>"; 
						}

					 ?>
              </select></td>
          </tr>
          <tr>
            <td style="text-align:right">Open/Closed:</td>
            <td><input type="radio" name="openclose" value="Open" />
              Open
              <input type="radio" name="openclose" value="Closed" />
              Closed
              <input type="radio" name="openclose" value="" checked="checked" />
              All</td>
          </tr>
          <tr>
            <td style="text-align:right">Men/Women:</td>
            <td><input type="radio" name="men_women" value="Men" />
              Men
              <input type="radio" name="men_women" value="Women" />
              Women
              <input type="radio" name="men_women" value="Both" />
              Both
              <input type="radio" name="men_women" value="" checked="checked" />
              All</td>
          </tr>
          <tr>
            <td colspan="2" style="text-align:center">
                <input type="submit" name="Submit" value="Search for Meetings" />
            </td>
          </tr>
        </table>
        <ul class="mtList">
            <li><a href="meeting_search_results.php">See All Meetings</a></li>
            <li><a href="../docs/MeetingList.pdf">Print Meeting List</a></li>
            <li><a href="javascript:;" onClick="MM_popupMsg('Please fill out the following form and return to the Northern Delaware Intergroup Office (21B Trolley Square, Wilmington, DE 19806');MM_openBrWindow('../flyers/NDIAA Group Form.pdf','','')">New/Change Meeting(s)?</a></li>
          </ul>
      </form>
      <p><strong>Directions:</strong>Make selections above then press <em>Search for Meetings</em> to see the meetings that meet your criteria.</p>
       <p>To search again just click Meetings.</p>
      <table style="width: 600">
			  <tbody><tr>
				  <td colspan="3">CODES FOR TYPE OF MEETING</td>
			  </tr>
               <?php mysql_data_seek($meeting_type_sql, 0); //re-set the array pointer to the first record since using this twice
			   while($row = mysql_fetch_array($meeting_type_sql)){
				  echo "<tr> <td style='width: 15%'>$row[code]</td><td style='width: 5%'></td><td style='width: 80%'>$row[description]</td></tr>";
			   } ?>
			  
		  </tbody></table>
  </div>
</div>
<?php mysql_close($conn); ?>
</body>
</html>